<?php

include 'Db.php';
include 'input.php';

    
    $size = $input->get("size");
    if($size){
        file_put_contents("./1.txt", $size);
    }

?>

<?php 

if(isset($_SESSION["user"]))echo "欢迎:".$_SESSION["user"];
    else echo "你还未登录";
    
    $pageNo = $input->get("pageNo");
    if($pageNo==null||$pageNo==""){
        $pageNo = 1;
    }
    $pageN = ($pageNo-1)*3;
    $sql = "select * from user where 1=1";
    $sql .= " order by id desc";
    
    $pageSize = file_get_contents("./1.txt");
    $sql .= " limit {$pageN},$pageSize";
    
   $res = $dbs->getQuery($sql);
    
    while($row = $res->fetch(5)){
        $rows[] = $row;
    }
  
?>

 <html style="text-align: center">
 	<head><title>ÏêÇéÒ³</title>
 	<script type="text/javascript" src="../js/jquery-1.8.3.min.js"></script>
 
 	</head>
 	<body >
 	<center>
 	<a href="login.php">·µ»Ø</a>
 	
 		<table border="2px" style="color:green;text-align: center">
 			<tr>
 				<td>ÐÕÃû</td>
 				<td>ÃÜÂë</td>
 				<td>ÊÓÆµÍ¼Æ¬</td>
 				<td>ÎÄ¼þ</td>
 				<td>Ê±¼ä</td>
 				<td>²Ù×÷</td>
 			</tr>
 			<?php 
 			  foreach ($rows as $r){
 			      $dates = $r->shijian;
 			      $time = date('Y-m-d h:i:s',$dates);
 			    ?>  
 			    <tr>
 				<td><?php echo $r->username?></td>
 				<td><?php echo $r->password?></td>
 				<td>
 			<a href="<?php echo '/phpcms/'.$r->photo?>" target="_blank">
 				<img alt="" src="<?php echo '/phpcms/'.$r->photo?>" width="100px" height="65px"> 
 			</a>
 	
 				</td>
 				<td>
 				
 				<a href="<?php echo '../'.$r->download?>">
 				 <?php echo $r->download?>
 				</a>
 				
 				</td>
 				<td><?php echo $time?></td>
 			<td>
 			<?php 
 			  
 			  if(!isset($_SESSION["user"])){
 			      echo 'ÄúÎ´µÇÂ¼';
 			      
 			?>
 				<?php }else{ ?>
 				
 				   <a href="update.php?id=<?php echo $r->id?>">ÐÞ¸Ä</a>||
 				   <button onclick="del(<?php echo $r->id?>)">É¾³ý</button>
 				 <!--  <a href="delete.php?id=<?php echo $r->id?>">É¾³ý</a> --> ||
 				   <a href="<?php echo '../'.$r->download?>">ÏÂÔØ</a>||
 				   <a href="detail.php?id=<?php echo $r->id?>">ÊÓÆµÏêÇé</a>
 			
 				<?php }?>
 				</td>
 			</tr>
 			   
 			<?php }
 			?>
 			
 			
 		</table>
 		
 		<br>
 	   <a href="list.php?pageNo=1">Ê×Ò³</a>
 		<?php 
 		  if($pageNo<=1){
 		      echo "ÉÏÒ»Ò³";
 		  }else{
 		?>
 		<a href="list.php?pageNo=<?php echo $pageNo-1?>">ÉÏÒ»Ò³</a>
 		<?php } ?>
 		
 		<?php 
 		  if($pageNo>=$dbs->end()){
 		      echo "ÏÂÒ»Ò³";
 		  }else{
 		?>
 		<a href="list.php?pageNo=<?php echo $pageNo+1?>">ÏÂÒ»Ò³</a>
 		<?php } ?>
 		
 		<a href="list.php?pageNo=<?php echo $dbs->end();?>">Î²Ò³</a>
 		
 		|| ×Ü¹²£º<?php echo $dbs->end()?>Ò³  ||Ã¿Ò³ÏÔÊ¾<input style="width: 30px" name="size" onblur="show(this.value)"/> Ìõ
 		<script type="text/javascript">

 			function del(a){
			  if(window.confirm("È·ÈÏÉ¾³ýÂð")){
					window.location.href = "delete.php?id=" + a;
			  }
			
 		    }
             function show(a){
                // alert("list.php" + "?size=" + a);
                 if(a==null||a==""){
					return;
                 }
                window.location.href = "list.php" + "?size=" + a;
             }
        	  
 	   </script>
 	   
 	
 	
 	<br>
     	<form action="save.php" method="post" enctype="multipart/form-data">
     		ÓÃ»§Ãû£º<input name="username"><br/><br/>
     		ÃÜÂë£º<input type="password" name="password"><br/><br/>
     		ÊÓÆµÍ¼Æ¬£º<input type="file" name="photo"><br/><br/>
     		ÎÄ¼þ£º<input type="file" name="download"><br/><br/>
     		ÊÓÆµÂ·¾¶£º<textarea rows="10" cols="20" name="video"></textarea><br/>
     		
     		<input type="submit" value="±£´æ"><input type="reset" value="ÖØÌî">
     	
     	</form>
 	
 	</body>
 	    </center>
 	<!-- 
 	<?php 
 	  $file =  file_get_contents("../1.txt");
 	    file_put_contents("../1.txt", "2222222",FILE_APPEND);
 	 // echo str_replace("\t","kongge",$file,FILE_APPEND);   
 	  echo $file;
 	?> 
 	 -->
 </html>